package com.rfs.java8;


import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;

public class ArryListTest {
    public static void main(String[] args) {
        int[] arr={4,3,2,2,2,1,1};
        System.out.printf("新数组："+ JSON.toJSONString(fun(arr)));
    }
    public static int[]  fun(int [] arr){
        if (arr.length==1){
            return arr;
        }
        int[] newArr=new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            if(newArr[arr[i]]>0){
                continue;
            }
            newArr[arr[i]]=arr[i];
        }
        return newArr;
    }
}
